import { Column, Entity, ManyToMany, PrimaryGeneratedColumn } from 'typeorm'

import { SysRoleEntity } from '.'
import { BaseEntity } from './base.entity'

@Entity()
export class SysDeptEntity extends BaseEntity implements ISysDeptEntity {
  @PrimaryGeneratedColumn({ type: 'bigint' })
  deptId: string

  @Column({ type: 'bigint' })
  parentId: string

  @Column()
  ancestors: string

  @Column()
  deptName: string

  @Column()
  orderNum: number

  @Column()
  leader: string

  @Column()
  phone: string

  @Column()
  email: string

  @Column()
  status: string

  @Column()
  delFlag: string

  @ManyToMany(type => SysRoleEntity, role => role.depts)
  roles: SysRoleEntity[]
}
